/*
 * TowerFactory.java
 *
 * Created on December 9, 2007, 3:48 PM
 *
 * Copyright (C) 2007-2008  Hylke van der Schaaf
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, in version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package hextd.tower;

import hextd.hex.Hex;
import hextd.util.Context;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author hylke
 */
public class TowerFactory {
    
    public static enum type {
        firecontrol("fc", TowerFireControl.price),
        upgradeDamage("ud", TowerUpgradeDamage.price),
        upgradeRange("ur", TowerUpgradeRange.price),
        greenOne("g1", TowerGreenOne.price),
        greenTwo("g2", TowerGreenTwo.price),
        greenThree("g3", TowerGreenThree.price),
        redOne("r1", TowerRedOne.price),
        redTwo("r2", TowerRedTwo.price),
        redThree("r3", TowerRedThree.price),
        yellowOne("y1", TowerYellowOne.price),
        yellowTwo("y2", TowerYellowTwo.price),
        yellowThree("y3", TowerYellowThree.price),
        blueOne("b1", TowerBlueOne.price),
        blueTwo("b2", TowerBlueTwo.price),
        blueThree("b3", TowerBlueThree.price);
        
        public final int price;
        public final String code;
        type(String code, int price) {
            this.price = price;
            this.code = code;
        }
    }
    public static Map<String, type> table = new HashMap<String, type>();
    static {
        for (type t : type.values()) {
            table.put(t.code, t);
        }
    }
    
    public static Tower createTower(type t, Context c, Hex h) {
        switch (t) {
            case upgradeDamage:
                return new TowerUpgradeDamage(c, h);
            case upgradeRange:
                return new TowerUpgradeRange(c, h);
            case firecontrol:
                return new TowerFireControl(c, h);
            case greenOne:
                return new TowerGreenOne(c, h);
            case greenTwo:
                return new TowerGreenTwo(c, h);
            case greenThree:
                return new TowerGreenThree(c, h);
            case redOne:
                return new TowerRedOne(c, h);
            case redTwo:
                return new TowerRedTwo(c, h);
            case redThree:
                return new TowerRedThree(c, h);
            case yellowOne:
                return new TowerYellowOne(c, h);
            case yellowTwo:
                return new TowerYellowTwo(c, h);
            case yellowThree:
                return new TowerYellowThree(c, h);
            case blueOne:
                return new TowerBlueOne(c, h);
            case blueTwo:
                return new TowerBlueTwo(c, h);
            case blueThree:
                return new TowerBlueThree(c, h);
        }
        return null;
    }
}
